﻿package cn.kxm.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.kxm.dao.OutstorageBillMapper;
import cn.kxm.pojo.OutstorageBill;
import cn.kxm.pojo.OutstorageBillDetail;
import cn.kxm.service.OutstorageBillService;
@Service
public class OutstorageBillServiceImpl implements OutstorageBillService{

	@Autowired
	private OutstorageBillMapper om;

	@Override
	public List<OutstorageBill> findAll(String code, String start, String end,
			String name, Integer page, Integer size) {
		return om.findAll(code, start, end, name, page, size);
	}

	@Override
	public int getCount(String code, String start, String end, String name) {
		// TODO Auto-generated method stub
		return om.getCount(code, start, end, name);
	}

	@Override
	public OutstorageBill findByCode(String code) {
		// TODO Auto-generated method stub
		return om.findByCode(code);
	}

	@Override
	public List<Map<String, Object>> getPart(String code) {
		// TODO Auto-generated method stub
		return om.getPart(code);
	}

	@Override
	public int addoB(OutstorageBill o) {
		// TODO Auto-generated method stub
		return om.addoB(o);
	}

	@Override
	public int addoBdetail(OutstorageBillDetail obd) {
		// TODO Auto-generated method stub
		return om.addoBdetail(obd);
	}

	@Override
	public int modifyoB(OutstorageBill o) {
		// TODO Auto-generated method stub
		return om.modifyoB(o);
	}

	@Override
	public int modifyoBdetail(OutstorageBillDetail obd) {
		// TODO Auto-generated method stub
		return om.modifyoBdetail(obd);
	}

	@Override
	public List<OutstorageBillDetail> getBycode(String code) {
		// TODO Auto-generated method stub
		return om.getBycode(code);
	}

	@Override
	public int deleteoB(String code) {
		// TODO Auto-generated method stub
		return om.deleteoB(code);
	}

	@Override
	public int deleteoBdetail(String code) {
		// TODO Auto-generated method stub
		return om.deleteoBdetail(code);
	}

	@Override
	public List<Map<String, Object>> findsell(String code, String start,
			String end, String name, Integer page, Integer size) {
		// TODO Auto-generated method stub
		return om.findsell(code, start, end, name, page, size);
	}

	@Override
	public int sellcount(String code, String name, String start, String end) {
		// TODO Auto-generated method stub
		return om.sellcount(code, name, start, end);
	}

	@Override
	public List<Map<String, Object>> getSellPart(String code) {
		// TODO Auto-generated method stub
		return om.getSellPart(code);
	}

	@Override
	public int updateStatus(Integer status,String code) {
		// TODO Auto-generated method stub
		return om.updateStatus(status,code);
	}

	@Override
	public int updateOutstorage(Integer amount, Double sellPrice,
			String partCode) {
		// TODO Auto-generated method stub
		return om.updateOutstorage(amount, sellPrice, partCode);
	}

	@Override
	public boolean updateAll(Integer status, String code, Integer amount,
			Double sellPrice, String partCode,String sellcode) {
		if(status==1){
			if(om.updateStatus(status, code)>0&&om.updateOnstorage(amount, partCode)>0){
				if(sellcode!=null){
					if(om.updatesellorder(status,sellcode)>0){
						return true;
					}
				}
				return true;
			}
		}else{
			if(om.updateStatus(status, code)>0&&om.updateOutstorage(amount, sellPrice, partCode)>0){
				if(sellcode!=null){
					if(om.updatesellorder(status,sellcode)>0){
						return true;
					}
				}
				return true;
			}
		}
		return false;
	}

	@Override
	public int updatesellorder(Integer outtype,String code) {
		// TODO Auto-generated method stub
		return om.updatesellorder(outtype,code);
	}

	@Override
	public int updateOnstorage(Integer amount, String partCode) {
		// TODO Auto-generated method stub
		return om.updateOnstorage(amount, partCode);
	}

	@Override
	public int findoutstatus(String sellcode) {
		// TODO Auto-generated method stub
		return om.findoutstatus(sellcode);
	}

	@Override
	public int findamount(String partCode) {
		// TODO Auto-generated method stub
		return om.findamount(partCode);
	}

	@Override
	public List<OutstorageBill> findout(String code, String start, String end,
			String name) {
		// TODO Auto-generated method stub
		return om.findout(code, start, end, name);
	}


}
